package com.xio.cloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: xio
 * @Description: 网关配置类
 * @Date: 2020/10/9 10:20
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customRoutes(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route_baidu_guonei", r -> r.path("/guonei")
                .uri("http://news.baidu.com/guonei")).build();

        routes.route("path_route_baidu_guoji", r -> r.path("/guoji")
                .uri("http://news.baidu.com/guoji")).build();

        return routes.build();
    }
}
